<?php

/**
 *	  [Discuz! X] (C)2001-2099 Comsenz Inc.
 *	  This is NOT a freeware, use is subject to license terms
 *
 *	  $Id: spacecp.inc.php 33645 2013-07-25 01:32:20Z nemohou $
 */

if(!defined('IN_DISCUZ')) {
	exit('Access Denied');
}

if(!$_G['uid']) {
	showmessage('not_loggedin', NULL, array(), array('login' => 1));
}

$pluginop = !empty($_GET['pluginop']) ? $_GET['pluginop'] : 'config';
if (!in_array($pluginop, array('config', 'share', 'new', 'sync_tthread'))) {
	showmessage('undefined_action');
}
$sh_type = trim(intval($_GET['sh_type']));
$tid = trim(intval($_GET['thread_id']));
if ($pluginop == 'config') {

	$_G['connect']['is_oauth_user'] = true;
	if (empty($_G['member']['conuinsecret'])) {
		$_G['connect']['is_oauth_user'] = false;
	}

	$referer = str_replace($_G['siteurl'], '', dreferer());
	if(!empty($_GET['connect_autoshare'])) {
		if(strpos($referer, '?') !== false) {
			$referer .= '&connect_autoshare=1';
		} else {
			$referer .= '?connect_autoshare=1';
		}
	}
	$connect_member = C::t('#qqconnect#common_member_connect')->fetch($_G['uid']);
	if ($connect_member) {
		$_G['member'] = array_merge($_G['member'], $connect_member);
		$user_auth_fields = $connect_member['conisfeed'];
		if ($user_auth_fields == 0) {
			$_G['member']['is_user_info'] = 0;
			$_G['member']['is_feed'] = 0;
		} elseif ($user_auth_fields == 1) {
			$_G['member']['is_user_info'] = 1;
			$_G['member']['is_feed'] = 1;
		} elseif ($user_auth_fields == 2) {
			$_G['member']['is_user_info'] = 1;
			$_G['member']['is_feed'] = 0;
		} elseif ($user_auth_fields == 3) {
			$_G['member']['is_user_info'] = 0;
			$_G['member']['is_feed'] = 1;
		}
		unset($connect_member, $_G['member']['conisfeed']);
	}
	$_G['connect']['loginbind_url'] = $_G['siteurl'].'connect.php?mod=login&op=init&type=loginbind&referer='.urlencode($_G['connect']['referer'] ? $_G['connect']['referer'] : 'index.php');

}